﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
<head>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
    <meta content="history" name="save">
    <title>SA1023: DereferenceAndAccessOfMustBeSpacedCorrectly</title>
    <link rel="stylesheet" type="text/css" href="stylesheets/helpstudio.css"><link rel="stylesheet" type="text/css" href="styles/Presentation.css">
    <script src="script/helpstudio.js" type="text/javascript"></script>
    <script src="script/StandardText.js" type="text/jscript"></script>    
</head>
<body id="hsbody">
        <input type="hidden" id="userDataCache" class="userDataStyle" name="userDataCache" />
        <div id="allHistory" class="saveHistory" onsave="saveScrollPosition()" onload="loadScrollPosition()"></div>
        <script type="text/jscript">WritePageTop(document.title);</script>
        <div id="pagebody">
            <div id="mainbody">
                <table>
                    <col />
                    <tr><td><p>TypeName</p></td><td><p>DereferenceAndAccessOfMustBeSpacedCorrectly</p></td></tr>
                    <tr><td><p>CheckId</p></td><td><p>SA1023</p></td></tr>
                    <tr><td><p>Category</p></td><td><p>Spacing Rules</p></td></tr>
                </table>           
                <h2>Cause</h2>
<P>A dereference symbol or an access-of symbol within a C# element is not spaced correctly.</P>
<H2>Rule Description</H2>
<P>A violation of this rule occurs when the spacing around a dereference or access-of symbol is not correct.</P>
<P>The spacing around the symbol depends upon whether the symbol is used within a type declaration. If so, the symbol must always be followed by a single space, unless it is the last character on the line, or is followed by an opening square bracket or a parenthesis. In addition, the symbol should not be preceded by whitespace, and should not be the first character on the line. An example of a properly spaced dereference symbol used within a type declaration is:</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 7.5pt"><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: blue; LINE-HEIGHT: 140%; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>object</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; LINE-HEIGHT: 140%; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-no-proof: yes">* x = <SPAN style="COLOR: blue">null</SPAN>;</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; LINE-HEIGHT: 140%"><o:p></o:p></SPAN></P>
<P>When a dereference or access-of symbol is used outside of a type declaration, the 
    opposite rule applies. In this case, the symbol must always be preceded by a 
    single space, unless it is the first character on the line, or is preceded by an 
    opening square bracket, a parenthesis or a symbol of the same type i.e. an 
    equals. The symbol should not be followed by whitespace, and should not be the&nbsp;last character on the line. For example:</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 7.5pt"><SPAN lang=EN-US style="FONT-SIZE: 9pt; COLOR: blue; LINE-HEIGHT: 140%; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; LINE-HEIGHT: 140%; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-no-proof: yes">y = *x;</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; LINE-HEIGHT: 140%"><o:p></o:p></SPAN></P>
<H2>How to Fix Violations</H2>
<P>To fix a violation of this rule, ensure that the spacing around the dereference or address-of symbol follows the rule described above.</SPAN></P>
 <h2>How to Suppress Violations</h2>
                <pre>[SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1023:DereferenceAndAccessOfMustBeSpacedCorrectly", Justification = "Reviewed.")]</pre>
    
        </div>
       <script type="text/jscript">WritePageFooter();</script>   
    </div>
</body>
</html>